<?php
date_default_timezone_set("PRC");

$dsn="mysql:Server=127.0.0.1;dbname=blog";
$db= new PDO($dsn, "root", "123456");
$db ->exec("set names utf8mb4");

$sql ="select * from category order by category_id desc";
$result =$db->query($sql);
$categoryList =$result->fetchAll(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="css/mian.css"/>
</head>
<body>
<div id="container">
    <div id="top">
        <h1>博客管理系统</h1>
        <div id="top_id">欢迎您：admin，<a href="#">退出登录</a></div>
    </div>
    <div id="left">
        <ul>
            <li><a href="category_list.php">分类管理</a></li>
            <li><a href="article_list.php">新闻管理</a></li>
<!--            <li><a href="#">管理员</a></li>-->
        </ul>
    </div>
    <div id="right">
        <div id="right_tao">
            <a href="#">首页</a>
            <a href="#">分类管理</a>
            <a href="#">分类列表</a>
        </div>
        <div id="table">
<!--            <button class="but">全选</button>-->
<!--            <a href="#">删除选中的任务</a>-->
            <a href="category_add.php" id="p">增加分类</a>
        </div>
        <div id="table_list">
            <table border="" cellspacing="" cellpadding="">
                <tr>
                    <th></th>
                    <th>分类Id</th>
                    <td>分类名称</td>
                    <td>分类描述</td>
                    <th>发表时间</th>
                    <th>修改时间</th>
                    <th>操作</th>
                </tr>
                <?php foreach ($categoryList as  $value): ?>
                <tr>
                    <td><input type="checkbox" /></td>
                    <td><?php echo $value['category_id']; ?></td>
                    <td><?php echo $value['category_name']; ?></td>
                    <td><?php echo $value['category_desc']; ?></td>
                    <td><?php echo date("Y-m-d H:i-s" ,$value['update_time']); ?></td>
                    <td><?php echo date("Y-m-d H:i-s" ,$value['add_time']); ?></td>
                    <td>
                        <a href="category_edit.php?category_id=<?php echo $value['category_id']; ?>">编辑</a>
                        <a href="category_delete.php?category_id=<?php echo $value['category_id']; ?>">删除</a>
                    </td>
                </tr>
                <?php endforeach; ?>
            </table>
        </div>
    </div>
</div>
</body>
</html>